package com.acwing.partition12;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/1/15 15:22
 */
public class AC1134最短路计数 {

    private static final int N = 100010, M = 400010, MOD = 100003, INF = 0x3f3f3f3f;
    private static int[] head = new int[N], element = new int[M], next = new int[M];
    private static int[] dist = new int[N], cnt = new int[N];

    private static int n = 0, m = 0, index = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        for (int i = 0; i < N; i++) head[i] = -1;
        for (int i = 0; i < m; i++) {
            s = reader.readLine().split("\\s+");
            int u = Integer.parseInt(s[0]), v = Integer.parseInt(s[1]);
            createEdge(u, v);
            createEdge(v, u);
        }
        bfs();
        for (int i = 1; i <= n; i++) writer.write(cnt[i] + "\n");
        writer.flush();
    }

    private static void bfs() {
        for (int i = 0; i < N; i++) dist[i] = INF;
        dist[1] = 0;
        cnt[1] = 1;
        Queue<Integer> queue = new LinkedList<>();
        queue.add(1);
        while (!queue.isEmpty()) {
            int u = queue.poll();
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = element[i];
                if (dist[v] > dist[u] + 1) {
                    dist[v] = dist[u] + 1;
                    cnt[v] = cnt[u];
                    queue.add(v);
                } else if (dist[v] == dist[u] + 1) {
                    cnt[v] = (cnt[v] + cnt[u]) % MOD;
                }
            }
        }
    }

    private static void createEdge(int u, int v) {
        element[index] = v;
        next[index] = head[u];
        head[u] = index++;
    }
}
